# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=jinja
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.10
pkgrel=1
pkgdesc="A simple pythonic template language written in Python (mingw-w64)"
arch=('any')
license=('BSD')
url="http://jinja.pocoo.org/"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-markupsafe"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-markupsafe")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/pallets/jinja/archive/${pkgver}.tar.gz)
sha256sums=('0d31d3466c313a9ca014a2d904fed18cdac873a5ba1f7b70b8fd8b206cd860d6')

build() {
  cd "${srcdir}"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r ${_realname}-${pkgver} ${builddir}
    pushd $builddir
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-jinja() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools" "${MINGW_PACKAGE_PREFIX}-python3-markupsafe")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-jinja() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" "${MINGW_PACKAGE_PREFIX}-python2-markupsafe")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-jinja() {
  package_python2-jinja
}

package_mingw-w64-i686-python3-jinja() {
  package_python3-jinja
}

package_mingw-w64-x86_64-python2-jinja() {
  package_python2-jinja
}

package_mingw-w64-x86_64-python3-jinja() {
  package_python3-jinja
}
